home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kshellcompletion.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  2.8 KB  |  86 lines

  1. /* This file is part of the KDE libraries
  2.     Copyright (C) 2000 David Smith  <dsmith@algonet.se>
  3.  
  4.     This library is free software; you can redistribute it and/or
  5.     modify it under the terms of the GNU Library General Public
  6.     License as published by the Free Software Foundation; either
  7.     version 2 of the License, or (at your option) any later version.
  8.  
  9.     This library is distributed in the hope that it will be useful,
  10.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12.     Library General Public License for more details.
  13.  
  14.     You should have received a copy of the GNU Library General Public License
  15.     along with this library; see the file COPYING.LIB.  If not, write to
  16.     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  17.     Boston, MA 02110-1301, USA.
  18. */
  19.  
  20. #ifndef KSHELLCOMPLETION_H
  21. #define KSHELLCOMPLETION_H
  22.  
  23. #include <qstring.h>
  24. #include <qstringlist.h>
  25.  
  26. #include "kurlcompletion.h"
  27.  
  28. class KShellCompletionPrivate;
  29.  
  30. /**
  31.  * This class does shell-like completion of file names.
  32.  * A string passed to makeCompletion() will be interpreted as a shell 
  33.  * command line. Completion will be done on the last argument on the line. 
  34.  * Returned matches consist of the first arguments (uncompleted) plus the 
  35.  * completed last argument.
  36.  *
  37.  * @short Shell-like completion of file names
  38.  * @author David Smith <dsmith@algonet.se>
  39.  */
  40. class KIO_EXPORT KShellCompletion : public KURLCompletion 
  41. {
  42.     Q_OBJECT
  43.  
  44. public:
  45.         /**
  46.          * Constructs a KShellCompletion object.
  47.          */
  48.     KShellCompletion();
  49.  
  50.     /**
  51.      * Finds completions to the given text.
  52.      * The first match is returned and emitted in the signal match().
  53.      * @param text the text to complete
  54.      * @return the first match, or QString::null if not found
  55.      */
  56.     QString makeCompletion(const QString &text);
  57.  
  58. protected:
  59.     // Called by KCompletion
  60.     void postProcessMatch( QString *match ) const;
  61.     void postProcessMatches( QStringList *matches ) const;
  62.         void postProcessMatches( KCompletionMatches *matches ) const;
  63.  
  64. private:
  65.     // Find the part of text that should be completed
  66.     void splitText(const QString &text, QString &text_start, QString &text_compl) const;
  67.     // Insert quotes and neseccary escapes
  68.     bool quoteText(QString *text, bool force, bool skip_last) const;
  69.     QString unquote(const QString &text) const;
  70.                                                                                 
  71.     QString m_text_start; // part of the text that was not completed
  72.     QString m_text_compl; // part of the text that was completed (unchanged)
  73.  
  74.     QChar m_word_break_char;
  75.     QChar m_quote_char1;
  76.     QChar m_quote_char2;
  77.     QChar m_escape_char;  
  78.                 
  79. protected:
  80.     virtual void virtual_hook( int id, void* data );
  81. private:
  82.     KShellCompletionPrivate *d;
  83. };
  84.  
  85. #endif // KSHELLCOMPLETION_H
  86.